<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="60px">
      <el-form-item label="户编号" prop="fid">
        <el-input
            v-model="queryParams.fid"
            placeholder="请输入户编号"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="name">
        <el-input
            v-model="queryParams.name"
            placeholder="请输入姓名"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
            <el-form-item label="证件号码" prop="idCard" label-width="70px">
              <el-input
                v-model="queryParams.idCard"
                placeholder="请输入证件号码"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="与户主关系" prop="relationship" label-width="88px">
              <el-select v-model="queryParams.relationship" placeholder="请选择与户主关系" clearable>
                <el-option
                  v-for="dict in base_family_relationship"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
      <!--      <el-form-item label="民族" prop="nationality">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.nationality"-->
      <!--          placeholder="请输入民族"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文化程度" prop="educationDegree">-->
      <!--        <el-select v-model="queryParams.educationDegree" placeholder="请选择文化程度" clearable>-->
      <!--          <el-option-->
      <!--            v-for="dict in dict.type.base_farmer_education_dearee"-->
      <!--            :key="dict.value"-->
      <!--            :label="dict.label"-->
      <!--            :value="dict.value"-->
      <!--          />-->
      <!--        </el-select>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="健康状况" prop="healthCondition">-->
      <!--        <el-select v-model="queryParams.healthCondition" placeholder="请选择健康状况" clearable>-->
      <!--          <el-option-->
      <!--            v-for="dict in dict.type.base_farmer_health_condition"-->
      <!--            :key="dict.value"-->
      <!--            :label="dict.label"-->
      <!--            :value="dict.value"-->
      <!--          />-->
      <!--        </el-select>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="劳动技能" prop="laborSkill">-->
      <!--        <el-select v-model="queryParams.laborSkill" placeholder="请选择劳动技能" clearable>-->
      <!--          <el-option-->
      <!--            v-for="dict in dict.type.base_farmer_labor_skill"-->
      <!--            :key="dict.value"-->
      <!--            :label="dict.label"-->
      <!--            :value="dict.value"-->
      <!--          />-->
      <!--        </el-select>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="致贫原因" prop="povertyCause">-->
      <!--        <el-select v-model="queryParams.povertyCause" placeholder="请选择致贫原因" clearable>-->
      <!--          <el-option-->
      <!--            v-for="dict in dict.type.base_farmer_poverty_cause"-->
      <!--            :key="dict.value"-->
      <!--            :label="dict.label"-->
      <!--            :value="dict.value"-->
      <!--          />-->
      <!--        </el-select>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="人员识别时间" prop="registrationTime">-->
      <!--        <el-date-picker clearable-->
      <!--          v-model="queryParams.registrationTime"-->
      <!--          type="date"-->
      <!--          value-format="yyyy-MM-dd"-->
      <!--          placeholder="请选择人员识别时间">-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="户状态" prop="state">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.state"-->
      <!--          placeholder="请输入户状态"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />
            </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="Plus"
            @click="handleAdd"
            v-hasPermi="['NH:farmer:add']"
        >新增
        </el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--            type="success"-->
<!--            plain-->
<!--            icon="Edit"-->
<!--            :disabled="single"-->
<!--            @click="handleUpdate"-->
<!--            v-hasPermi="['NH:farmer:edit']"-->
<!--        >修改-->
<!--        </el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--            type="danger"-->
<!--            plain-->
<!--            icon="Delete"-->
<!--            :disabled="multiple"-->
<!--            @click="handleDelete"-->
<!--            v-hasPermi="['NH:farmer:remove']"-->
<!--        >删除-->
<!--        </el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--            type="warning"-->
<!--            plain-->
<!--            icon="Download"-->
<!--            @click="handleExport"-->
<!--            v-hasPermi="['NH:farmer:export']"-->
<!--        >导出-->
<!--        </el-button>-->
<!--      </el-col>-->
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="farmerList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center"/>
<!--           <el-table-column label="ID" align="center" prop="id" />-->
      <el-table-column label="户编号" align="center" prop="fid"/>
      <el-table-column label="姓名" align="center" prop="name"/>
      <el-table-column label="证件号码" align="center" prop="idCard"/>
      <el-table-column label="自然村" align="center" prop="natVillage">
        <template #default="scope">
          <dict-tag :options="base_nature_village" :value="scope.row.natVillage"/>
        </template>
      </el-table-column>
      <el-table-column label="与户主关系" align="center" prop="relationship">
        <template  #default="scope">
          <dict-tag :options="base_family_relationship" :value="scope.row.relationship"/>
        </template>
      </el-table-column>
      <!--      <el-table-column label="民族" align="center" prop="nationality" />-->
      <!--      <el-table-column label="文化程度" align="center" prop="educationDegree">-->
      <!--        <template slot-scope="scope">-->
      <!--          <dict-tag :options="base_farmer_education_dearee" :value="scope.row.educationDegree"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="在校情况" align="center" prop="studentStatus" />-->
      <!--      <el-table-column label="健康状况" align="center" prop="healthCondition">-->
      <!--        <template slot-scope="scope">-->
      <!--          <dict-tag :options="base_farmer_health_condition" :value="scope.row.healthCondition"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="劳动技能" align="center" prop="laborSkill">-->
      <!--        <template slot-scope="scope">-->
      <!--          <dict-tag :options="base_farmer_labor_skill" :value="scope.row.laborSkill"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
            <el-table-column label="贫困原因" align="center" prop="povertyCause">
              <template #default="scope">
                <dict-tag :options="base_farmer_poverty_cause" :value="scope.row.povertyCause"/>
              </template>
            </el-table-column>
      <!--      <el-table-column label="人员识别时间" align="center" prop="registrationTime" width="180">-->
      <!--        <template slot-scope="scope">-->
      <!--          <span>{{ parseTime(scope.row.registrationTime, '{y}-{m}-{d}') }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
<!--      <el-table-column label="户状态" align="center" prop="state"/>-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-tooltip content="修改" placement="top" v-if="scope.row.id !== 0">
            <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
                       v-hasPermi="['NH:farmer:edit']"></el-button>
          </el-tooltip>
          <el-tooltip content="删除" placement="top" v-if="scope.row.id !== 0">
            <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
                       v-hasPermi="['NH:farmer:remove']"></el-button>
          </el-tooltip>
          <el-tooltip content="转移户主" placement="top" v-if="scope.row.id !== 0">
            <el-button link type="primary" icon="user"  @click="handleTransfer(scope.row)"
                       v-hasPermi="['NH:farmer:transform']"></el-button>
          </el-tooltip>

        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改农户基本信息对话框 -->
    <el-dialog :title="title" v-model="open" width="750px" append-to-body>
      <el-form ref="farmerRef" :model="form" :rules="rules" label-width="108px">
<!--        <el-form-item label="编号" prop="id">-->
<!--          <el-input v-model="form.id" placeholder="请输入编号"/>-->
<!--        </el-form-item>-->
        <el-form-item label="户编号" prop="fid" v-if="isHuZhu">
          <el-input v-model="form.fid" placeholder="请输入户编号"/>
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名"/>
        </el-form-item>
        <el-form-item label="证件号码" prop="idCard">
          <el-input v-model="form.idCard" placeholder="请输入证件号码"/>
        </el-form-item>
        <el-form-item label="自然村" prop="natVillage" v-if="isHuZhu">
          <el-select v-model="form.natVillage" placeholder="请输入自然村">
            <el-option
                    v-for="dict in base_nature_village"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="与户主关系" prop="relationship" >
          <el-select v-model="form.relationship" placeholder="请选择与户主关系">
            <el-option
                v-for="dict in base_family_relationship"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="民族" prop="nationality">
          <el-input v-model="form.nationality" placeholder="请输入民族"/>
        </el-form-item>
        <el-form-item label="文化程度" prop="educationDegree">
          <el-select v-model="form.educationDegree" placeholder="请选择文化程度">
            <el-option
                v-for="dict in base_farmer_education_dearee"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
          <el-form-item label="在校情况" prop="studentStatus">
              <el-input v-model="form.studentStatus" placeholder="请输入在校情况"/>
          </el-form-item>
        <el-form-item label="健康状况" prop="healthCondition">
          <el-select v-model="form.healthCondition" placeholder="请选择健康状况">
            <el-option
                v-for="dict in base_farmer_health_condition"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="劳动技能" prop="laborSkill">
          <el-select v-model="form.laborSkill" placeholder="请选择劳动技能">
            <el-option
                v-for="dict in base_farmer_labor_skill"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="致贫原因" prop="povertyCause">
          <el-select v-model="form.povertyCause" placeholder="请选择致贫原因">
            <el-option
                v-for="dict in base_farmer_poverty_cause"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="人员识别时间" prop="registrationTime">
          <el-date-picker clearable
                          v-model="form.registrationTime"
                          type="date"
                          value-format="YYYY-MM-DD"
                          placeholder="请选择人员识别时间">
          </el-date-picker>
        </el-form-item>
          <el-form-item label="耕种面积" prop="area" v-if="isHuZhu">
              <el-input v-model="form.area" placeholder="请输入耕种面积"/>
          </el-form-item>
          <el-form-item label="户联系电话" prop="phone" v-if="isHuZhu">
              <el-input v-model="form.phone" placeholder="请输入户联系电话"/>
          </el-form-item>
          <el-form-item label="户类别" prop="familyType" v-if="isHuZhu">
              <el-select v-model="form.familyType" placeholder="请选择户类别" clearable>
                  <el-option
                          v-for="dict in base_family_type"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                  />
              </el-select>
          </el-form-item>
<!--        <el-form-item label="户状态" prop="state">-->
<!--          <el-input v-model="form.state" placeholder="请输入户状态"/>-->
<!--        </el-form-item>-->
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <!-- 转移户主基本信息对话框 -->
    <el-dialog :title="title" v-model="openTransferHuZhu" width="750px" append-to-body>
          <div class="app-container">
            <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="60px">
              <el-form-item label="户编号" prop="fid">
                <el-input v-model="queryParams.fid" placeholder="请输入户编号" clearable @keyup.enter.native="handleQuery" />
              </el-form-item>
              <el-form-item label="姓名" prop="name">
                <el-input v-model="queryParams.name" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" />
              </el-form-item>
              <el-form-item label="证件号码" prop="idCard" label-width="70px">
                <el-input v-model="queryParams.idCard" placeholder="请输入证件号码" clearable @keyup.enter.native="handleQuery" />
              </el-form-item>
              <el-form-item label="与户主关系" prop="relationship" label-width="88px">
                <el-select v-model="queryParams.relationship" placeholder="请选择与户主关系" clearable>
                  <el-option v-for="dict in base_family_relationship" :key="dict.value" :label="dict.label" :value="dict.value" />
                </el-select>
              </el-form-item>
            </el-form>
          </div>
          <br /><br />
          <div>
            <h4 class="form-header h4">与户主关系变更</h4>
          </div>
          <el-table :data="farmers" class="table">
            <el-table-column label="姓名" prop="name"></el-table-column>
            <el-table-column label="与户主关系">
              <template slot-scope="scope">
                <el-select v-model="scope.row.relationship" placeholder="请选择与户主关系" clearable>
                  <el-option v-for="option in relationshipOptions" :key="option.value" :label="option.label" :value="option.value"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="与新户主关系">
              <template slot-scope="scope">
                <el-select v-model="scope.row.newRelationship" placeholder="请选择与新户主关系" clearable>
                  <el-option v-for="option in relationshipOptions" :key="option.value" :label="option.label" :value="option.value"></el-option>
                </el-select>
              </template>
            </el-table-column>
          </el-table>
          <hr />
          <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
<!--            这两个按钮的js方法还没有写-->
              <el-button class="btn-primary btn-rounded btn-sm" @click="submitForm">保存</el-button>
              <el-button class="btn-warning btn-rounded btn-sm" @click="cancelTransferHuZhu">关闭</el-button>
            </div>
          </div>
        </el-dialog>




    <!-- 删除户主对话框 -->
    <el-dialog :title="title" v-model="openDelHuZhu" width="750px" append-to-body>
      删除户主
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitDelHuZhuForm">确 定</el-button>
          <el-button @click="cancelDelHuZhu">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import {
  listFarmer, getFarmer, delFarmer, addFarmer, updateFarmer,TransferFarmer,
  conNatVillageList, conRelationshipList, conHealthConditionList,
  conLaborSkillList, conPovertyCauseList, conFamilyTypeList, conEducationDegreeList, delHuZhu,transferHuZhu
} from "@/api/NH/farmer";

const router = useRouter();
const {proxy} = getCurrentInstance();
const {
  base_farmer_poverty_cause,
  base_family_relationship,
  base_farmer_health_condition,
  base_farmer_education_dearee,
  base_farmer_labor_skill,
  base_nature_village,
  base_family_type,
} = proxy.useDict("base_farmer_poverty_cause", "base_family_relationship", "base_farmer_health_condition", "base_farmer_education_dearee", "base_farmer_labor_skill","base_nature_village","base_family_type");

// 遮罩层
const loading = ref(true);
// 选中数组
const ids = ref([]);
// 非单个禁用
const single = ref(true);
// 非多个禁用
const multiple = ref(true);
// 显示搜索条件
const showSearch = ref(true);
// 总条数
const total = ref(0);
// 农户基本信息表格数据***
const farmerList = ref([]);
// 弹出层标题
const title = ref("");
// 是否显示弹出层
const open = ref(false);
// 是否显示删除户主弹出层
const openDelHuZhu = ref(false);
// 转移户主弹出框
const openTransferHuZhu = ref(false);
const dateRange = ref([]);

const data = reactive({
  // 表单校验
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    fid: null,
    admVillage: null,
    natVillage: null,
    name: null,
    phone: null,
    num: null,
    area: null,
    relationship: null,
    state: null,
  },
  rules: {
    fid: [
      {required: true, message: "户编号不能为空", trigger: "blur"}
    ],
    name: [
      {required: true, message: "姓名不能为空", trigger: "blur"}
    ],
    idCard: [
      {required: true, message: "证件号码不能为空", trigger: "blur"}
    ],
    relationship: [
      {required: true, message: "与户主关系不能为空", trigger: "change"}
    ],
    nationality: [
      {required: true, message: "民族不能为空", trigger: "blur"}
    ],
    healthCondition: [
      {required: true, message: "健康状态不能为空", trigger: "change"}
    ],
    laborSkill: [
      {required: true, message: "劳动技能不能为空", trigger: "change"}
    ],
    povertyCause: [
      {required: true, message: "致贫原因不能为空", trigger: "change"}
    ],
    registrationTime: [
      {required: true, message: "人员识别时间不能为空", trigger: "blur"}
    ],
    state: [
      {required: true, message: "户状态不能为空", trigger: "blur"}
    ]
  }
});

const {queryParams, form, rules} = toRefs(data);

const isHuZhu = ref(true);


/** 查询农户基本信息列表 */
function getList() {
  loading.value = true;
  listFarmer(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
    farmerList.value = res.rows;
    total.value = res.total;
    loading.value = false;
  });
}

/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
};

/** 删除户主弹出框的取消按钮 */
function cancelDelHuZhu() {
  openDelHuZhu.value = false;
  // reset();
};

// 表单重置
function reset() {
  form.value = {
    id: 0,
    fid: null,
    name: null,
    idCard: null,
    relationship: null,
    nationality: null,
    educationDegree: null,
    studentStatus: null,
    healthCondition: null,
    laborSkill: null,
    povertyCause: null,
    registrationTime: [],
    state: null
  };
  proxy.resetForm("farmerRef");
};

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
};

/** 重置按钮操作 */
function resetQuery() {
  dateRange.value = [];
  proxy.resetForm("queryForm");
  handleQuery();
};

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id)
  single.value = selection.length !== 1
  multiple.value = !selection.length
};



/** 新增按钮操作 */
function handleAdd() {
  reset();
  const id = form.value.id
  getFarmer(id).then(response => {
    open.value = true;
    title.value = "添加农户基本信息";
  });
};
/** 转移户主按钮操作 */
function handleTransfer() {
  reset(); // Assuming you have a reset function to clear the form fields

  // Assuming you have a form object with an 'id' field
  const id = form.value.id;

  getFarmer(id) // Assuming you have a function to fetch farmer information
      .then(response => {
        // Assuming you have variables to control the modal, title, etc.
        openTransferHuZhu.value = true;
        title.value = "转移户主"; // Set the modal title for transferring owner
      })
      .catch(error => {
        console.error("Error fetching farmer information:", error);
      });
}
/** 转移户主弹出框的取消按钮 */
function cancelTransferHuZhu() {
  openDelHuZhu.value = false;
  // reset();
};
// Usage example:
// You can call this function when a button or action triggers the transfer owner process.
// For instance, in a Vue.js method, you can use it like this:
// methods: {
//   transferOwnerButtonClicked() {
//     handleTransferOwner();
//   }
// }

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const id = row.id || ids.value
  getFarmer(id).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = "修改农户基本信息";
    if(form.value.relationship !== 1){
        isHuZhu.value = false
    }
    else{
        isHuZhu.value = true
    }
    // console.log(conNatVillageList[form.value.natVillage].listValue === '大六合')
    // console.log(form.value.familyType)
    // console.log(conNatVillageList[form.value.familyType])
    form.value.natVillage = conNatVillageList[form.value.natVillage].listValue
    form.value.relationship = conRelationshipList[form.value.relationship].listValue
    form.value.healthCondition = conHealthConditionList[form.value.healthCondition].listValue
    form.value.laborSkill = conLaborSkillList[form.value.laborSkill].listValue
    form.value.povertyCause = conPovertyCauseList[form.value.povertyCause].listValue
    if(form.value.familyType !== null){
      form.value.familyType = conFamilyTypeList[form.value.familyType].listValue
    }
    // form.value.familyType = conFamilyTypeList[form.value.familyType].listValue
    form.value.educationDegree = conEducationDegreeList[form.value.educationDegree].listValue
  });
};

/** 提交按钮 */
function submitForm() {
  conForm();
  proxy.$refs["farmerRef"].validate(valid => {
    if (valid) {
      if (form.value.id != 0) {
        updateFarmer(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addFarmer(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
};

/** 删除户主弹出框提交按钮 */
function submitDelHuZhuForm() {
  delHuZhu(form.value)
  proxy.$modal.msgSuccess("删除成功");
  openDelHuZhu.value = false;
  getList();
};

/** 删除按钮操作 */
function handleDelete(row) {
    //单删与多删都走此方法
  const ids = row.id || ids.value;
  const relationship = row.relationship || relationship.value;
  proxy.$modal.confirm('是否确认删除农户基本信息编号为"' + ids + '"的数据项？').then(function () {
    if (relationship == 1){
      proxy.$modal.confirm('请再次确认是否删除此户主？').then(function () {
        handleDeleteHuZhu(row)
        // openDelHuZhu.value = true;
        // title.value = "删除户主";
        // router.push({path:'/NH/farmer/delHuZhu'});
        // return delHuZhu(ids);
      }).catch(() => {
      });
    }else {
      return delFarmer(ids);
    }
  }).then(() => {
    getList();
  }).catch(() => {
  });
};

function handleDeleteHuZhu(row){

}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('NH/farmer/export', {
    ...queryParams.value
  }, `farmer_${new Date().getTime()}.xlsx`);
};
//回显需要转换成值，提交到数据库需要转换成键
/** 转换表单 */
function conForm(){
  if(form.value.natVillage === conNatVillageList[1].listValue){
    form.value.natVillage = 1
  }else if(form.value.natVillage === conNatVillageList[2].listValue){
    form.value.natVillage = 2
  }else if(form.value.natVillage === conNatVillageList[3].listValue){
    form.value.natVillage = 3
  }else if(form.value.natVillage === conNatVillageList[4].listValue){
    form.value.natVillage = 4
  }else if(form.value.natVillage === conNatVillageList[5].listValue){
    form.value.natVillage = 5
  }else if(form.value.natVillage === conNatVillageList[6].listValue){
    form.value.natVillage = 6
  }else if(form.value.natVillage === conNatVillageList[7].listValue){
    form.value.natVillage = 7
  }else if(form.value.natVillage === conNatVillageList[8].listValue){
    form.value.natVillage = 8
  }
  if(form.value.relationship === conRelationshipList[1].listValue){
    form.value.relationship = 1
  }else if(form.value.relationship === conRelationshipList[2].listValue){
    form.value.relationship = 2
  }else if(form.value.relationship === conRelationshipList[3].listValue){
    form.value.relationship = 3
  }else if(form.value.relationship === conRelationshipList[4].listValue){
    form.value.relationship = 4
  }else if(form.value.relationship === conRelationshipList[5].listValue){
    form.value.relationship = 5
  }else if(form.value.relationship === conRelationshipList[6].listValue){
    form.value.relationship = 6
  }else if(form.value.relationship === conRelationshipList[7].listValue){
    form.value.relationship = 7
  }else if(form.value.relationship === conRelationshipList[8].listValue){
    form.value.relationship = 8
  }else if(form.value.relationship === conRelationshipList[9].listValue){
    form.value.relationship = 9
  }else if(form.value.relationship === conRelationshipList[10].listValue){
    form.value.relationship = 10
  }
  if(form.value.healthCondition === conHealthConditionList[1].listValue){
    form.value.healthCondition = 1
  }else if(form.value.healthCondition === conHealthConditionList[2].listValue){
    form.value.healthCondition = 2
  }else if(form.value.healthCondition === conHealthConditionList[3].listValue){
    form.value.healthCondition = 3
  }else if(form.value.healthCondition === conHealthConditionList[4].listValue){
    form.value.healthCondition = 4
  }else if(form.value.healthCondition === conHealthConditionList[5].listValue){
    form.value.healthCondition = 5}
  // }else if(form.value.healthCondition === conHealthConditionList[6].listValue){
  //   form.value.healthCondition = 6
  // }else if(form.value.healthCondition === conHealthConditionList[7].listValue){
  //   form.value.healthCondition = 7
  // }else if(form.value.healthCondition === conHealthConditionList[8].listValue){
  //   form.value.healthCondition = 8
  // }
  if(form.value.laborSkill === conLaborSkillList[1].listValue){
    form.value.laborSkill = 1
  }else if(form.value.laborSkill === conLaborSkillList[2].listValue){
    form.value.laborSkill = 2
  }else if(form.value.laborSkill === conLaborSkillList[3].listValue){
    form.value.laborSkill = 3
  }else if(form.value.laborSkill === conLaborSkillList[4].listValue){
    form.value.laborSkill = 4}
  // }else if(form.value.laborSkill === conLaborSkillList[5].listValue){
  //   form.value.laborSkill = 5
  // }else if(form.value.laborSkill === conLaborSkillList[6].listValue){
  //   form.value.laborSkill = 6
  // }else if(form.value.laborSkill === conLaborSkillList[7].listValue){
  //   form.value.laborSkill = 7
  // }else if(form.value.laborSkill === conLaborSkillList[8].listValue){
  //   form.value.laborSkill = 8
  // }
  if(form.value.povertyCause === conPovertyCauseList[1].listValue){
    form.value.povertyCause = 1
  }else if(form.value.povertyCause === conPovertyCauseList[2].listValue){
    form.value.povertyCause = 2
  }else if(form.value.povertyCause === conPovertyCauseList[3].listValue){
    form.value.povertyCause = 3
  }else if(form.value.povertyCause === conPovertyCauseList[4].listValue){
    form.value.povertyCause = 4
  }else if(form.value.povertyCause === conPovertyCauseList[5].listValue){
    form.value.povertyCause = 5
  }else if(form.value.povertyCause === conPovertyCauseList[6].listValue){
    form.value.povertyCause = 6
  }else if(form.value.povertyCause === conPovertyCauseList[7].listValue){
    form.value.povertyCause = 7}
  // }else if(form.value.povertyCause === conPovertyCauseList[8].listValue){
  //   form.value.povertyCause = 8
  // }
  if(form.value.familyType === conFamilyTypeList[1].listValue){
    form.value.familyType = 1
  }else if(form.value.familyType === conFamilyTypeList[2].listValue){
    form.value.familyType = 2
  }else if(form.value.familyType === conFamilyTypeList[3].listValue){
    form.value.familyType = 3
  }else if(form.value.familyType === conFamilyTypeList[4].listValue){
    form.value.familyType = 4
  }else if(form.value.familyType === conFamilyTypeList[5].listValue){
    form.value.familyType = 5}
  // }else if(form.value.familyType === conFamilyTypeList[6].listValue){
  //   form.value.familyType = 6
  // }else if(form.value.familyType === conFamilyTypeList[7].listValue){
  //   form.value.familyType = 7
  // }else if(form.value.familyType === conFamilyTypeList[8].listValue){
  //   form.value.familyType = 8
  // }
  if(form.value.educationDegree === conEducationDegreeList[1].listValue){
    form.value.educationDegree = 1
  }else if(form.value.educationDegree === conEducationDegreeList[2].listValue){
    form.value.educationDegree = 2
  }else if(form.value.educationDegree === conEducationDegreeList[3].listValue){
    form.value.educationDegree = 3
  }else if(form.value.educationDegree === conEducationDegreeList[4].listValue){
    form.value.educationDegree = 4
  }else if(form.value.educationDegree === conEducationDegreeList[5].listValue){
    form.value.educationDegree = 5}
  // }else if(form.value.educationDegree === conEducationDegreeList[6].listValue){
  //   form.value.educationDegree = 6
  // }else if(form.value.educationDegree === conEducationDegreeList[7].listValue){
  //   form.value.educationDegree = 7
  // }else if(form.value.educationDegree === conEducationDegreeList[8].listValue){
  //   form.value.relationship = 8
  // }
}
getList();
</script>
